Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modmod

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modmod

make require-ing modules less require-y.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

modmod

make require-ing modules less require-y.

Getting Started

$ npm install --save modmod

Then, change your code from:

var fs = require('fs');
var chalk = require('chalk');
var wiredep = require('wiredep');

fs.writeFile('results.json', wiredep(), function (err) {
  if (err) {
    console.log(chalk.red.bold(err));
  }
});

...to...

var $ = require('modmod')('fs', 'chalk', 'wiredep');

$.fs.writeFile('results.json', $.wiredep(), function (err) {
  if (err) {
    console.log($.chalk.red.bold(err));
  }
});

Local vs External Modules

modmod is only intended to be used with external (npm-land) modules, and Node's native modules (http, fs, etc.). If you would like to namespace your local modules, you are welcome to assign additional objects on top of the object modmod returns. As an example:

var $ = require('modmod')('fs', 'chalk', 'wiredep');

$.local = {
  helpers: require('./helpers'),
  utils: require('./utils')
};

Why use modmod?

It's up to you. There's nothing wrong with the current system of multiple var declarations, and having too many isn't a node problem. Regardless, you may still consider it useful to namespace your dependencies under a name of your choosing, such as M or $, freeing up those "global" variables for use without conflicts.

License

MIT © Stephen Sawchuk

Keywords

FAQs

Package last updated on 07 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc